package com.fan.jicheng.homework;

import java.util.Objects;

public class Monkey {
    private   String  name;
    private   double  weight=10.0;

    public String getName() {
        return name;
    }

    public double getWeight() {
        return weight;
    }

    public Monkey(String name, double weight) {
        this.name = name;
        this.weight = weight;
    }

    @Override
    public String toString() {
        return "Monkey{" +
                "name='" + name + '\'' +
                ", weight=" + weight +
                '}';
    }

    public void   eat(Food  food){
        toString();
        System.out.println(food.getName());
        weight=food.getYingYangZhi()*0.1;
    }
    public  void   game(){
        if (weight<5){
            weight=weight;
        }else {
            weight=weight-0.05;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Monkey monkey = (Monkey) o;
        return Double.compare(monkey.weight, weight) == 0 &&
                Objects.equals(name, monkey.name);
    }

}
